/*
 *  Copyright 2019-2023 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.order.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

/**
 * @description /
 * @author yiwei.he
 * @date 2024-03-29
 **/
@Data
@TableName("tz_pay_order")
public class PayOrder implements Serializable {

    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty(value = "自增id")
    private Long id;

    @ApiModelProperty(value = "订单单号")
    private String orderSn;

    @ApiModelProperty(value = "交易状态，枚举值：SUCCESS：支付成功 REFUND：转入退款 NOTPAY：未支付 CLOSED：已关闭REVOKED：已撤销（仅付款码支付会返回）USERPAYING：用户支付中（仅付款码支付会返回）PAYERROR：支付失败（仅付款码支付会返回）")
    private Integer tradeState;

    @ApiModelProperty(value = "微信后台生成的订单号")
    private String transactionId;

    @ApiModelProperty(value = "交易类型【交易类型，枚举值：JSAPI：公众号支付NATIVE：扫码支付 APP：APP支付 MICROPAY：付款码支付 MWEB：H5支付 FACEPAY：刷脸支付】")
    private String tradeType;

    @ApiModelProperty(value = "总金额，默认为分")
    private Integer total;

    @ApiModelProperty(value = "支付方式【1：微信支付】")
    private Integer payment;

    @ApiModelProperty(value = "订单创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "订单完成时间")
    private LocalDateTime successTime;

    @ApiModelProperty(value = "说明")
    private String remark;

    @ApiModelProperty(value = "用户id")
    private Long userId;

    @ApiModelProperty(value = "商品id")
    private Long pId;

    @ApiModelProperty(value = "购买数量")
    private Integer number;

    @ApiModelProperty(value = "订单类型【vip订单，商品订单】")
    private String orderType;

    @ApiModelProperty(value = "运费")
    private BigDecimal fee;

    @ApiModelProperty(value = "省/市/区")
    private String provinceCityRegion;

    @ApiModelProperty(value = "收货人姓名")
    private String recName;

    @ApiModelProperty(value = "收货人电话")
    private String recPhone;

    @ApiModelProperty(value = "收货人地址")
    private String recAddress;

    @ApiModelProperty(value = "快递公司编码")
    private String kdCode;

    @ApiModelProperty(value = "快递公司名")
    private String kdName;

    @ApiModelProperty(value = "快递单号")
    private String kdOrder;

    @ApiModelProperty(value = "1-未售后 2-售后中 3-已售后")
    private Integer soldStatus;

    @ApiModelProperty(value = "订单过期时间")
    private LocalDateTime expireTime;

    @ApiModelProperty(value = "发货状态【0：未发货 1：已发货】")
    private Integer logisticsStatus;

    public void copy(PayOrder source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
